import 'package:flutter/material.dart';

class Mydialog extends Dialog {
  String title;
  String ctent;
  void Function() closeBtn;
  Mydialog({
    super.key,
    required this.title,
    required this.ctent,
    required this.closeBtn,
  });

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency, //设置背景透明
      child: Center(
        //主要包裹一个组件  不然会全屏
        child: Container(
          width: 240,
          height: 240,
          color: Colors.white,
          child: Column(
            children: [
              Padding(
                padding: EdgeInsets.all(5),
                child: Stack(
                  children: [
                    Align(
                      alignment: Alignment.centerLeft,
                      child: Text(title, style: TextStyle(fontSize: 18)),
                    ),
                    Align(
                      alignment: Alignment.centerRight,
                      child: InkWell(
                        child: Icon(Icons.close),
                        onTap: () {
                          closeBtn();
                        },
                      ),
                    ),
                  ],
                ),
              ),

              Divider(),
              Container(padding: EdgeInsets.all(5), child: Text(ctent)),
            ],
          ),
        ),
      ),
    );
  }
}
